/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vfaq.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vfaq.model.FAQCategoryQuestion;
import com.vportal.portlet.vfaq.model.FAQCategoryQuestionModel;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the FAQCategoryQuestion service. Represents a row in the &quot;FAQCategoryQuestion&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vfaq.model.FAQCategoryQuestionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FAQCategoryQuestionImpl}.
 * </p>
 *
 * @author DucNN
 * @see FAQCategoryQuestionImpl
 * @see com.vportal.portlet.vfaq.model.FAQCategoryQuestion
 * @see com.vportal.portlet.vfaq.model.FAQCategoryQuestionModel
 * @generated
 */
public class FAQCategoryQuestionModelImpl extends BaseModelImpl<FAQCategoryQuestion>
	implements FAQCategoryQuestionModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a f a q category question model instance should use the {@link com.vportal.portlet.vfaq.model.FAQCategoryQuestion} interface instead.
	 */
	public static final String TABLE_NAME = "FAQCategoryQuestion";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "id_", Types.BIGINT },
			{ "questionId", Types.BIGINT },
			{ "categoryId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table FAQCategoryQuestion (uuid_ VARCHAR(75) null,id_ LONG not null primary key,questionId LONG,categoryId LONG)";
	public static final String TABLE_SQL_DROP = "drop table FAQCategoryQuestion";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vfaq.model.FAQCategoryQuestion"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vfaq.model.FAQCategoryQuestion"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vfaq.model.FAQCategoryQuestion"),
			true);
	public static long CATEGORYID_COLUMN_BITMASK = 1L;
	public static long QUESTIONID_COLUMN_BITMASK = 2L;
	public static long UUID_COLUMN_BITMASK = 4L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vfaq.model.FAQCategoryQuestion"));

	public FAQCategoryQuestionModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return FAQCategoryQuestion.class;
	}

	public String getModelClassName() {
		return FAQCategoryQuestion.class.getName();
	}

	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_id = id;
	}

	public long getQuestionId() {
		return _questionId;
	}

	public void setQuestionId(long questionId) {
		_columnBitmask |= QUESTIONID_COLUMN_BITMASK;

		if (!_setOriginalQuestionId) {
			_setOriginalQuestionId = true;

			_originalQuestionId = _questionId;
		}

		_questionId = questionId;
	}

	public long getOriginalQuestionId() {
		return _originalQuestionId;
	}

	public long getCategoryId() {
		return _categoryId;
	}

	public void setCategoryId(long categoryId) {
		_columnBitmask |= CATEGORYID_COLUMN_BITMASK;

		if (!_setOriginalCategoryId) {
			_setOriginalCategoryId = true;

			_originalCategoryId = _categoryId;
		}

		_categoryId = categoryId;
	}

	public long getOriginalCategoryId() {
		return _originalCategoryId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public FAQCategoryQuestion toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (FAQCategoryQuestion)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					FAQCategoryQuestion.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		FAQCategoryQuestionImpl faqCategoryQuestionImpl = new FAQCategoryQuestionImpl();

		faqCategoryQuestionImpl.setUuid(getUuid());
		faqCategoryQuestionImpl.setId(getId());
		faqCategoryQuestionImpl.setQuestionId(getQuestionId());
		faqCategoryQuestionImpl.setCategoryId(getCategoryId());

		faqCategoryQuestionImpl.resetOriginalValues();

		return faqCategoryQuestionImpl;
	}

	public int compareTo(FAQCategoryQuestion faqCategoryQuestion) {
		long primaryKey = faqCategoryQuestion.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		FAQCategoryQuestion faqCategoryQuestion = null;

		try {
			faqCategoryQuestion = (FAQCategoryQuestion)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = faqCategoryQuestion.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		FAQCategoryQuestionModelImpl faqCategoryQuestionModelImpl = this;

		faqCategoryQuestionModelImpl._originalUuid = faqCategoryQuestionModelImpl._uuid;

		faqCategoryQuestionModelImpl._originalQuestionId = faqCategoryQuestionModelImpl._questionId;

		faqCategoryQuestionModelImpl._setOriginalQuestionId = false;

		faqCategoryQuestionModelImpl._originalCategoryId = faqCategoryQuestionModelImpl._categoryId;

		faqCategoryQuestionModelImpl._setOriginalCategoryId = false;

		faqCategoryQuestionModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<FAQCategoryQuestion> toCacheModel() {
		FAQCategoryQuestionCacheModel faqCategoryQuestionCacheModel = new FAQCategoryQuestionCacheModel();

		faqCategoryQuestionCacheModel.uuid = getUuid();

		String uuid = faqCategoryQuestionCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			faqCategoryQuestionCacheModel.uuid = null;
		}

		faqCategoryQuestionCacheModel.id = getId();

		faqCategoryQuestionCacheModel.questionId = getQuestionId();

		faqCategoryQuestionCacheModel.categoryId = getCategoryId();

		return faqCategoryQuestionCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", id=");
		sb.append(getId());
		sb.append(", questionId=");
		sb.append(getQuestionId());
		sb.append(", categoryId=");
		sb.append(getCategoryId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vfaq.model.FAQCategoryQuestion");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>questionId</column-name><column-value><![CDATA[");
		sb.append(getQuestionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>categoryId</column-name><column-value><![CDATA[");
		sb.append(getCategoryId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = FAQCategoryQuestion.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			FAQCategoryQuestion.class
		};
	private String _uuid;
	private String _originalUuid;
	private long _id;
	private long _questionId;
	private long _originalQuestionId;
	private boolean _setOriginalQuestionId;
	private long _categoryId;
	private long _originalCategoryId;
	private boolean _setOriginalCategoryId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private FAQCategoryQuestion _escapedModelProxy;
}